<?php
include_once ROOT_DIR."/bc/block.percust.php";
function bend_percust(&$retparams){
	global $_db;
	
	if(!isset($_POST['op'])){
		return BEND_REDIRECT;
	}
	elseif("addview"==$_POST['op']){
		echo rendertpl("applet/percustaddmod.applet", array("title"=>"添加案例"));
		return BEND_RENDERED;
	}
	elseif("add"==$_POST['op']){
		$id = addpercust($_POST);
		if($id>0){
			$retparams['errorcode'] = 0;
		}
		else{
			$retparams['errorcode'] = -1;
		}
		return BEND_ECHORET;
	}
	elseif("del"==$_POST['op']){
		$count = $_db->delete("percust", "id=$_POST[id]");
	}
	elseif("modview"==$_POST['op']){
		echo rendertpl("applet/percustaddmod.applet", array("title"=>"修改案例"));
		return BEND_RENDERED;
	}
	elseif("mod"==$_POST['op']){
		$count = $_db->update("percust", array("name"=>@$_POST['name'],"gender"=>@$_POST['gender'],"mobile"=>@$_POST['mobile'],"othercontact"=>@$_POST['othercontact'],"city"=>@$_POST['city'],"address"=>@$_POST['address'],"age"=>@$_POST['age'],"workstatus"=>@$_POST['workstatus'],"orgtype"=>@$_POST['orgtype'],"workremark"=>@$_POST['workremark'],"married"=>@$_POST['married'],"cplworkstatus"=>@$_POST['cplworkstatus'],"cplorgtype"=>@$_POST['cplorgtype'],"cplworkremark"=>@$_POST['cplworkremark'],"incomelvl"=>@$_POST['incomelvl'],"incometype"=>@$_POST['incometype'],"incomeremark"=>@$_POST['incomeremark'],"curworktime"=>@$_POST['curworktime'],"curworkremark"=>@$_POST['curworkremark'],"hashouse"=>@$_POST['hashouse'],"houseremark"=>@$_POST['houseremark'],"hascar"=>@$_POST['hascar'],"carremark"=>@$_POST['carremark'],"credit"=>@$_POST['credit'],"creditremark"=>@$_POST['creditremark'],"debt"=>@$_POST['debt'],"debtremark"=>@$_POST['debtremark'],"remark"=>@$_POST['remark']),"id=$_POST[id]");
		if($count>0){
			$retparams['errorcode'] = 0;
		}
		else{
			$retparams['errorcode'] = -1;
		}
		return BEND_ECHORET;
	}
	elseif("search"==$_POST['op']){
		return BEND_HOMEPAGE;
	}
	return BEND_REDIRECT;
}
?>